<template>
  <div class="content">
    <van-nav-bar
      title="拼团优惠"
      left-text=""
      left-arrow
      @click-left="onClickLeft"
    />
    <van-swipe :autoplay="3000" indicator-color="white">
      <van-swipe-item>
        <div class="banner">
          <img src="../../assets/tuangou.png" alt="">
        </div>
      </van-swipe-item>
      <van-swipe-item>
        <div class="banner">
          <img src="../../assets/tuangou.png" alt="">
        </div>
      </van-swipe-item>
    </van-swipe>
    <div class="goods" v-for="(item,index) in list" :key="index" @click="Details(item.gid)">
      <div class="img">
        <img :src="item.img" alt="">
      </div>
      <div class="right">
        <div class="title">
          {{item.name}}
        </div>
        <div class="sign">
          <div>{{item.assemble_num}}人参团</div>
          <div>{{item.num}}人团</div>
        </div>
        <div class="bottom">
          <div class="price">
            <div>￥{{item.price}}</div>
            <div>￥{{item.market_price}}</div>
          </div>
          <div @click="goTuan" class="bottom-right">去开团</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import request from '../../utils/request.js'

export default {
  name: 'groupList',
  data () {
    return {
      list: '',
      page: 1,
      pagesize: 20
    }
  },
  methods: {
    // 开团
    goTuan(){
      // window.location.href="http://app.ztsx123.com/1/#/one?"
    },
    onClickLeft() {
      this.$router.go(-1)
    },
    getList(){
      request({
        url: `?controller=theapi3&action=assembleGoods`,
        method: 'get',
        params:{
          page: this.page,
          pagesize: this.pagesize
        }
      }).then(res=>{
        this.list = res.data;
        console.log(res)
      })
    },
    Details(id){
      this.$router.push({
        name: 'Group-details',
        params: {
          id: id
        }
      })
    }
  },
  created(){
    this.getList()
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.van-nav-bar__text{
  color: #191E2A;
}
.van-nav-bar .van-icon{
  color: #191E2A;
}
.banner{
  position: relative;
  width: 100%;
  height: 100%;
  > img{
    width: 100%;
    height: 100%;
  }
}
.goods{
  position: relative;
  display: flex;
  margin: 0 0 0 0.2rem;
  padding: 0.4rem 0.2rem 0.4rem 0;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.01rem solid #EFF1F3;
  > .img{
    width: 2.28rem;
    height: 2.28rem;
    border: 0.02rem solid #DDE1E3;
    border-radius: 0.2rem;
    overflow: hidden;
    > img{
      width: 100%;
      height: 100%;
    }
  }
  .right{
    position: relative;
    flex-grow: 1;
    margin: 0 0 0 0.31rem;
    height: 2.28rem;
    .title{
      font-size: 0.28rem;
      font-weight: 600;
    }
    .sign{
      margin: 0.2rem 0 0 0;
      display: flex;
      justify-content: flex-start;
      >div{
        margin: 0 0.2rem 0 0;
        padding: 0 0.3rem;
        text-align: center;
        line-height: 0.5rem;
        border: 1px solid #FF6D40;
        background: #FFE8E1;
        border-radius: 0.2rem;
        color: #FF6D40;
      }
    }
    .bottom{
      position: absolute;
      bottom: 0;
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      >.price{
        display: flex;
        align-items: center;
        >div{
          font-size: 0.34rem;
          color: #F52E67;
        }
        >div:last-of-type{
          font-size: 0.26rem;
          color: #B3B5B8;
          margin: 0 0 0 0.1rem;
        }
      }
      >.bottom-right{
        font-size: 0.34rem;
        color: #F52E67;
        // font-weight: 600;
      }
    }
  }
}
</style>
